<%@ page language="java" import="java.util.*,cn.jbit.util.Page,cn.jbit.entity.*,cn.jbit.biz.*,
cn.jbit.biz.impl.*" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>分页</title>
</head>
<body>
	<%
	int pageIndex = 1;//获得当前页数
    if(request.getParameter("pageIndex") != null){
        pageIndex = Integer.parseInt(request.getParameter("pageIndex").toString());
    }/*Integer.parseInt:一般用在 输入对话框,因为输入对话框只认为输入为string,当输入整数时需要这个转换*/
    Page pages=new Page();
    pages.setCurrPageNo(pageIndex);    //设置当前页面
    pages.setPageSize(5);    //设置每页条数
    UserBiz userBiz=new UserBizImpl();
    int totalCount = userBiz.getUserListCount();
    pages.setTotalCount(totalCount);
    List<User> list = userBiz.getUserList(pages);
	%>
	<table border="1" width="300" cellpadding="0" cellspacing="0">
		<tr>
			<td>ID</td>
			<td>用户名</td>
    	    <td>密码</td>
		</tr>
	<%
		int totalpages=pages.getTotalPageCount();  //总页数
		for(User user:list){
	%>

		<tr>
			<td><%=user.getUid()%></td>
    	     <td><%=user.getUname() %></td>
    	     <td><%=user.getUpwd()%></td>
		</tr>
	<%
		}
	%>
	</table>
	当前页数：[<%=pageIndex %>/<%=totalpages %>]
	<%
	if(pageIndex>1){
	%>
	<a href="fenye.jsp?pageIndex=1">首页</a>&nbsp;
	<a href="fenye.jsp?pageIndex=<%=pageIndex-1 %>">上一页</a>
	<%	}
	if(pageIndex<totalpages){
	%>
	<a href="fenye.jsp?pageIndex=<%= pageIndex +1%>">下一页</a>
    <a href="fenye.jsp?pageIndex=<%=totalpages%>">末页</a> 
	<% } 
	%>
	<%/*?的意思:如果是在动态网页中，后面的问号大部分是进行传递参数用的。也就是把当前页面的参数通过地址栏的形式传递到下一页,
			?:代表传递参数,给当前页传递传递参数,多个参数用&连接.如:?topage=1&topage2=2*/ %>
</body>
</html>